package com.distributed.netty.entity;



import java.io.Serializable;
import java.util.UUID;

/**
 * @desc 元素任务
 * @author gzy
 * @time 2022-06-04
 */
public class ElementJob implements Serializable {
    private String id;

    public ElementJob() {
        id=System.currentTimeMillis()+UUID.randomUUID().toString();
    }

    /**缓存基本元素的KV*/
    private Object[] args;
    /**任务类型*/
    private JobType jobType;

    /**消息*/
    private String msg;

    public ElementJob(JobType jobType, Object[] args, String msg) {
        this.jobType = jobType;
        this.args = args;
        this.msg = msg;
        id=System.currentTimeMillis()+ UUID.randomUUID().toString();
    }

    public JobType getJobType() {
        return jobType;
    }

    public void setJobType(JobType jobType) {
        this.jobType = jobType;
    }

    public Object[] getArgs() {
        return args;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public boolean equals(Object obj) {
//        System.err.println("ElementJob equals方法被执行");
        ElementJob o = (ElementJob) obj;
//        System.err.println("obj="+o+", this="+id);
        return id.equals(o.id);
    }

    @Override
    public int hashCode() {
//        System.err.println("ElementJob hashCode方法被执行");
        return id.hashCode();
    }
}
